<template>
  <el-upload
    class="upload-demo"
    name="video"
    drag
    action="http://192.168.43.49:8080/shixun/uploadVideo"
    multiple
    :on-success="handleVideoSuccess"
    :before-upload="beforeVideoUpload"
  >
    <el-icon class="el-icon--upload"><upload-filled /></el-icon>
    <div class="el-upload__text">
      将文件拖到此处，或<em>点击上传</em>
    </div>
    <!-- <template #tip>
      <div class="el-upload__tip">
        只能上传mp4/flv/avi文件，且不超过300M
      </div>
    </template> -->
  </el-upload>

 
</template>

<script setup lang="ts">
import {defineEmits} from 'vue'
import { UploadFilled } from '@element-plus/icons-vue'
import type { UploadProps } from 'element-plus'
import { ElMessage } from 'element-plus'
const emits=defineEmits(['uploadVideo'])
const handleVideoSuccess: UploadProps['onSuccess'] = (
    response,
    uploadFile
  ) => {
    emits("uploadVideo",response.data)
  }
  
  const beforeVideoUpload: UploadProps['beforeUpload'] = (rawFile) => {
    // if (rawFile.type !== 'image/jpeg') {
    //   ElMessage.error('Avatar picture must be JPG format!')
    //   return false
    // } else if (rawFile.size / 1024 / 1024 > 2) {
    //   ElMessage.error('照片大小不能超过2MB!')
    //   return false
    // }
    return true
  }
</script>
